#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.common.exception;

import ${package}.common.emum.DadyEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;

import java.util.List;

/**
 * Description: ValidException
 *
 * @author wupanhua
 * @date 2019/8/6 15:28
 *
 * <pre>
 *              ${copyright}
 *      Copyright (c) 2019. All Rights Reserved.
 * </pre>
 */
@Slf4j
public class ValidException extends BusinessException {

    public ValidException() {
        super();
    }

    public ValidException(List<ObjectError> allErrors, DadyEnum dadyEnum) {

        super(dadyEnum);

        for (ObjectError error: allErrors) {
            if (error instanceof FieldError) {
                FieldError fieldError = (FieldError) error;
                log.error("校验信息:{}, 字段:{}", error.getDefaultMessage(), fieldError.getField());
            }
            log.error("校验信息:{}, 字段:{}", error.getDefaultMessage(), "无法识别");
        }
    }

    public ValidException(DadyEnum dady) {
        super(dady);
    }
}
